import pandas as pd


def read_csv():
    filepath = "../datas/beijing_tianqi/beijing_tianqi_2017-2019.csv"
    df = pd.read_csv(filepath)

    df["bWendu"] = df["bWendu"].map(lambda x : int(str(x).replace("℃", "")))
    df["yWendu"] = df["yWendu"].map(lambda x : int(str(x).replace("℃", "")))


    df[['温差','平均温度']] = df.apply(add_col,axis=1,result_type="expand")

    print(df.head())


# 同时添加温差，平均温度
def add_col(row):
    return row['bWendu'] - row['yWendu'],(row['bWendu'] - row['yWendu'])/2






if __name__ == "__main__":
    read_csv()